package org.achartengine.internal.chart;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import com.github.mikephil.charting.utils.Utils;
import java.util.ArrayList;
import org.achartengine.internal.renderer.XYMultipleSeriesRenderer;

/* loaded from: classes2.dex */
public class BarChart extends k {
    private static final int a = 12;
    public static final String b = "Bar";
    private static final long serialVersionUID = 1;
    protected Type c;
    private ArrayList<Rect> h;
    private int i;

    /* loaded from: classes2.dex */
    public enum Type {
        DEFAULT,
        STACKED
    }

    protected float a() {
        return 1.0f;
    }

    @Override // org.achartengine.internal.chart.a
    public int a(int i) {
        return 12;
    }

    @Override // org.achartengine.internal.chart.k
    public double b() {
        return Utils.DOUBLE_EPSILON;
    }

    @Override // org.achartengine.internal.chart.k
    public String c() {
        return b;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public BarChart() {
        this.c = Type.DEFAULT;
        this.h = new ArrayList<>();
        this.i = -1;
    }

    public BarChart(org.achartengine.internal.model.g gVar, XYMultipleSeriesRenderer xYMultipleSeriesRenderer, Type type) {
        super(gVar, xYMultipleSeriesRenderer);
        this.c = Type.DEFAULT;
        this.h = new ArrayList<>();
        this.i = -1;
        this.c = type;
    }

    /* JADX WARN: Code restructure failed: missing block: B:13:0x0078, code lost:
        if ((r1 - r37) == 0.0f) goto L7;
     */
    /* JADX WARN: Code restructure failed: missing block: B:14:0x007a, code lost:
        r32.h.add(new android.graphics.Rect(0, 0, 0, 0));
        r5 = r3;
        r21 = r4;
        r23 = r11;
     */
    /* JADX WARN: Code restructure failed: missing block: B:7:0x0069, code lost:
        if ((r37 - r2) == 0.0f) goto L7;
     */
    @Override // org.achartengine.internal.chart.k
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public void a(android.graphics.Canvas r33, android.graphics.Paint r34, float[] r35, org.achartengine.internal.renderer.b r36, float r37, int r38) {
        /*
            Method dump skipped, instructions count: 646
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: org.achartengine.internal.chart.BarChart.a(android.graphics.Canvas, android.graphics.Paint, float[], org.achartengine.internal.renderer.b, float, int):void");
    }

    @Override // org.achartengine.internal.chart.k
    protected void a(Canvas canvas, org.achartengine.internal.model.h hVar, Paint paint, float[] fArr, int i) {
        int a2 = this.d.a();
        float a3 = a(fArr, fArr.length, a2);
        for (int i2 = 0; i2 < fArr.length; i2 += 2) {
            float f = fArr[i2];
            if (this.c == Type.DEFAULT) {
                f += ((i * 2) * a3) - ((a2 - 1.0f) * a3);
            }
            a(canvas, a(hVar.c(i2 / 2)), f, fArr[i2 + 1] - 3.5f, paint, 0.0f);
        }
    }

    @Override // org.achartengine.internal.chart.a
    public void a(Canvas canvas, org.achartengine.internal.renderer.b bVar, float f, float f2, int i, Paint paint) {
        canvas.drawRect(f, f2 - 6.0f, f + 12.0f, f2 + 6.0f, paint);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public float a(float[] fArr, int i, int i2) {
        int i3 = i - 2;
        float f = fArr[i3] - fArr[0];
        if (i == 4) {
            i3 = 2;
        }
        float f2 = f / i3;
        f2 = (f2 == 0.0f || Float.isInfinite(f2)) ? 10.0f : 10.0f;
        if (this.c != Type.STACKED) {
            f2 /= i2;
        }
        double d = f2;
        double a2 = a();
        Double.isNaN(a2);
        Double.isNaN(d);
        return (float) (d / (a2 * (this.e.Y() + 1.0d)));
    }

    protected float b(float[] fArr, int i, int i2) {
        float f = (fArr[1] - fArr[i - 1]) / (i != 4 ? i - 2 : 2);
        f = (f == 0.0f || Float.isInfinite(f)) ? 10.0f : 10.0f;
        if (this.c != Type.STACKED) {
            f /= i2;
        }
        double d = f;
        double a2 = a();
        Double.isNaN(a2);
        Double.isNaN(d);
        return (float) (d / (a2 * (this.e.Y() + 1.0d)));
    }

    @Override // org.achartengine.internal.chart.a
    /* renamed from: b */
    public org.achartengine.internal.model.b a(float f, float f2) {
        org.achartengine.internal.model.h b2 = this.d.b(0);
        for (int i = 0; i < this.h.size(); i++) {
            if (this.h.get(i).contains((int) f, (int) f2)) {
                this.i = i;
                return new org.achartengine.internal.model.b(this.e.a(Double.valueOf(b2.b(i))), Double.valueOf(b2.c(i)));
            }
        }
        this.i = -1;
        return null;
    }
}
